<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>统计报表-客户</title>

    <!-- bootstrap -->
    <link href="__CSS__/bootstrap/bootstrap.css" rel="stylesheet" />

    <!-- libraries -->
    <!-- <link href="css/libs/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" /> -->
    <link href="__CSS__/libs/font-awesome.css" type="text/css" rel="stylesheet" />

    <!-- global styles -->
    <link rel="stylesheet" type="text/css" href="__CSS__/compiled/layout.css">
    <link rel="stylesheet" type="text/css" href="__CSS__/compiled/elements.css">

    <!-- this page specific styles -->
    <link rel="stylesheet" type="text/css" href="__CSS__/libs/bootstrap-wizard.css">
    <link rel="stylesheet" href="__CSS__/libs/select2.css" type="text/css" />

    <!-- Favicon -->
    <!--<link type="image/x-icon" href="favicon.png" rel="shortcut icon"/>-->

    <!-- google font libraries -->
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300|Titillium+Web:200,300,400' rel='stylesheet' type='text/css'>

    <script>
        (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
        })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

        ga('create', 'UA-49262924-1', 'phoonio.com');
        ga('send', 'pageview');

    </script>
</head>
<body>
<!--head-->
{include file="pub/head"/}

<div class="container" role="main">
    <div class="row">

        <!--left-->
        {include file="pub/left"/}

        <div class="col-md-10" id="content-wrapper">
            <!--<h2 class="pull-left">Last orders</h2>-->
            <div class="row">
                <div class="main-box">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title pull-right">
                                <label style="font-size: 24px;color: #0e90d2;width: 100px;">美元汇率</label>
                                <input type="text" name="rate" value="" id="rate" onchange="newCharts()" placeholder="默认:6.5" style="width: 100px;height: 36px;line-height: 36px;border-radius: 5px;">
                            </div>
                            <div class="x_content">

                                <div  class="col-md-12 col-sm-12 col-xs-12">
                                    <div class="x_panel tile">
                                        <div class="x_content">
                                            <table class="">
                                                <tr>
                                                    <th class="col-lg-8 col-md-8 col-sm-8 col-xs-12">
                                                        <p style="font-size: 18px;">订单总额对比图-按客户分</p>
                                                        <hr/>
                                                    </th>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <canvas id="graphC" class="canvasDoughnut" height="600" width="900" style="margin: 15px 10px 10px 0;overflow: scroll;" ></canvas>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>

                </div>
            </div>

            <!--</div>
        </div>-->
        </div>
    </div>
</div>
<!--foot-->
{include file="pub/foot"/}

<!-- global scripts -->
<script src="__JS__/jquery.js"></script>

<script src="__JS__/bootstrap.min.js"></script>

<!-- this page specific scripts -->
<script src="__JS__/bootstrap-wizard.js"></script>
<script src="__JS__/select2.min.js"></script>

<!-- theme scripts -->
<script src="__JS__/scripts.js"></script>
<script src="__JS__/echarts.js"></script>

<script>
    var myChartC = echarts.init(document.getElementById('graphC'));
    //console.log(myChartC)
    defaultRate(myChartC)
    function defaultRate(myChartC) {
        var graphC = '{$graphyC}';
        //console.log(graphC)
        graphC = JSON.parse(graphC);
        changeRate(graphC, myChartC)
    }
    function changeRate(graphC, myChartC) {
        /*for client*/
        var client = [];
        var dataC = [];
        for(var j=0;j<graphC.length;j++){
            dataC[j] = {value:graphC[j]['value'],name:graphC[j]['client']}
            client[j] = graphC[j]['client']
        }

        optionC = {
            // backgroundColor:'grey',
            tooltip: {
                trigger: 'item',
                show:true,
                formatter: "{a} <br/>{b} : {c} ({d}%)"
                // formatter: "{b} : {c} ({d}%)"
            },
            legend: {
                orient: 'vertical',
                type:"scroll",
                show:true,
                left: 'left',
                data: client,
                formatter:function (name) {
                    return (name.length > 15?(name.slice(0,15)+"..."):name);
                }
            },
            series : [
                {
                    name: '订单总额',
                    type: 'pie',
                    radius : '46%',
                    center: ['52%', '39%'],
                    label:{            //饼图图形上的文本标签
                        normal:{
                            show:true,
                            // position:'inner',
                            textStyle : {
                                fontWeight : 300 ,
                                fontSize : 14    //文字的字体大小
                            },
                            // formatter:'{d}%'
                            // formatter:'{b}:{d}%'
                            //formatter:'{b}:{c}￥'
                            formatter:function (params) {
                                return ((params.data.name.length > 15?params.data.name.slice(0,15)+'..':params.data.name)+':'+params.percent+'%');
                            }
                        }
                    },
                    data:dataC,
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                }
            ],
            toolbox: {
                show : false,
                feature : {
                    mark : {show: true},
                    dataView : {show: true, readOnly: true},
                    magicType : {
                        show: true,
                        type: ['pie', 'funnel'],
                        option: {
                            funnel: {
                                x: '25%',
                                width: '50%',
                                funnelAlign: 'left',
                                max: 1548
                            }
                        }
                    },
                    restore : {show: true},
                    saveAsImage : {show: true}
                }
            },
        };

        // 使用刚指定的配置项和数据显示图表。
        myChartC.setOption(optionC);
    }

    function newCharts() {
        //改变汇率
        var rate = $('#rate').val();
        //console.log(rate)
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: "{:url('Execorder/jsonGraphC')}",//url
            data: {'rate':rate},
            success: function (result) {
                //console.log(result)
                var graph = result;
                changeRate(graph, myChartC);
            },
            error:function (result) {
                //console.log('error'+result)
                alert('服务出错')
            }
        });
    }
</script>
</body>
</html>